/*
 * FileName: StopThread.java
 * Author:   zzw
 * Date:     2018年05月12日
 * Description:
 */
package com.zzw.thread;

/**
 * 〈停止线程〉<br>
 * 〈〉
 *
 * @author zzw
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本]（可选）
 */
public class StopThread extends Thread {

    private boolean stop = false;
    private Object lock;

    public StopThread(Object lock){
        this.lock = lock;
    }

    public void stopMe(){
        stop = true;
    }

    @Override
    public void run() {
        while(true){
            if (stop){
                System.out.println("exit by stop me");
                break;
            }
            synchronized (lock){
                //............
            }
        }
    }
}
